﻿@page "/admin/post"

@using ZLJ.App.Admin.Post
@using ZLJ.App.Admin.Post.Dto

@attribute [ReuseTabsPageTitle("员工岗位权限")]
@attribute [Authorize(PermissionNames.AdministratorBaseInfoPost)]
@inherits AdminListBaseComponent<IPostAppService, PostDto, int, PagedAndSortedResultRequest< PagedPostResultRequestDto>, CreatePostDto, PostEditDto>

<Space Direction="DirectionVHType.Vertical" Style="width:100%;">
    <SpaceItem>
        <GridRow Justify="space-between">
            @* 左侧 *@
            <GridCol Span="6">
                @if (createIsGranted)
                {
                    <Button Type="@ButtonType.Primary" Icon="@IconType.Outline.Plus" OnClick="ShowCreateDialog">新增</Button>
                }
                @if (deleteIsGranted)
                {
                    <Popconfirm Title="确定删除已选择的项吗?"
                                OnConfirm="Delete"
                                OnCancel="HideDeleteConfirm">
                        <Button Type="@ButtonType.Default" Icon="@IconType.Outline.Clear" Danger="true" Disabled="@ShouldDisableDelete">删除</Button>
                    </Popconfirm>
                }
            </GridCol>
            @* 右侧 *@
            <GridCol Span="18" Flex=@("none")>
                <Space>
                    <SpaceItem>
                        <RadioGroup TValue="bool?" @bind-Value="@GetAllInput.Filter.IsStatic" OnChange="Refresh">
                            <Radio TValue="bool?" RadioButton="true" Value="@(default(bool?))">全部</Radio>
                            <Radio TValue="bool?" RadioButton="true" Value="@(true)">预设</Radio>
                            <Radio TValue="bool?" RadioButton="true" Value="@(false)">非预设</Radio>
                        </RadioGroup>
                    </SpaceItem>

                    <SpaceItem>
                        <Search Placeholder="请输入关键字..." @bind-Value="@Keywords" OnSearch="Refresh" AllowClear="true" ClassicSearchIcon="true" />
                    </SpaceItem>
                    <SpaceItem>
                        <ButtonGroup>
                            @* <Button Type="@ButtonType.Default" Icon="@IconType.Outline.Search" OnClick="AddRandomData">搜索</Button> *@
                            <Tooltip Title="清空条件">
                                <Button Type="@ButtonType.Default" Icon="@IconType.Outline.Clear" OnClick="Reset"></Button>
                            </Tooltip>
                        </ButtonGroup>
                    </SpaceItem>

                </Space>

            </GridCol>
        </GridRow>

    </SpaceItem>
    <SpaceItem>
        <Table TItem="PostDto"
        @ref="table"
               Total="TotalCount"
        @bind-PageIndex="PageIndex"
        @bind-PageSize="PageSize"
        @bind-SelectedRows="SelectedItems"
               OnChange="OnQuery"
               DataSource="Items"
               Loading="IsLoading"
               RemoteDataSource="true"
               ScrollY="69.78vh"
               ScrollBarWidth="10px"
               Size="TableSize.Small"
               Bordered="true">

            <Selection Key="@(context.Id.ToString())" />
            <PropertyColumn Property="c=>c.DisplayName" Sortable="true" DefaultSortOrder="SortDirection.Ascending" ShowSorterTooltip="false" />
            @* <PropertyColumn Property="c=>c.Name" /> *@
            <PropertyColumn Property="c=>c.IsStatic">
                <Switch @bind-Value="@context.IsStatic" Size="@InputSize.Small" Disabled="true"></Switch>
            </PropertyColumn>
            <PropertyColumn Property="c=>c.Description" />
            <ActionColumn Title="操作">
                @* ButtonGroup设置Size好像没啥卵用 *@
                <ButtonGroup Size="@ButtonSize.Small">
                    <Button Size="@ButtonSize.Small" Type="@ButtonType.Primary">详情</Button>
                    @if (updateIsGranted)
                    {
                        <Button Size="@ButtonSize.Small">修改</Button>
                    }
                    @if (deleteIsGranted)
                    {
                        <Popconfirm Title="确定删除此项吗?"
                                    OnConfirm="()=>Delete(context)"
                                    OnCancel="HideDeleteConfirm">
                            <Button Size="@ButtonSize.Small" Danger="true">删除</Button>
                        </Popconfirm>
                    }
                </ButtonGroup>
            </ActionColumn>
        </Table>
    </SpaceItem>
</Space>

<AbpCreateDialog TAppService="IPostAppService" TEntityDto="PostDto" TPrimaryKey="int"
                 TGetAllInput="PagedAndSortedResultRequest<PagedPostResultRequestDto>"
                 TCreateInput="CreatePostDto" TUpdateInput="PostEditDto" TCreateComponent="Create" 
@ref="dalRef">

</AbpCreateDialog>

